import {
  FSMonitorGraphInfo,
  FSMonitorTableInfo,
  FSConfigInfo,
  SessionCenterGraphInfo,
  SessionCenterTableInfo,
  SessionCenterConfigInfo,
} from 'admin/schema/RealTimeMonitor';
import $http from '../../../servers/http';
import { Result } from '../../schema/Result';
/* 监控告警
---------------------------------------------------------------- */
/**
 * 获取FS Media监控数据
 * @param data.query 查询时间段（空值：近两分钟 ；日期精确到天）
 */
export const getFSGraphInfo = (
  fsName: string,
  data: { beginTime?: string; endTime?: string; interval?: number }
): Promise<Result<FSMonitorGraphInfo[]>> => {
  return $http.get({
    url: `/monitor/fss/${fsName}/monitoritem`,
    data,
  });
};

/**
 * 获取FS Media监控表格数据
 */
export const getFSTableData = (data: {
  beginTime?: string;
  endTime?: string;
}): Promise<Result<FSMonitorTableInfo[]>> => {
  return $http.get({
    url: `/monitor/fss/monitorlist`,
    data,
  });
};

/**
 * 编辑FS
 */
export const modifyFSConfig = (data: FSConfigInfo[]): Promise<Result<null>> => {
  return $http.post({
    url: `/monitor/fss`,
    data,
  });
};

/**
 * 获得FS列表
 */
export const getFSConfigList = (): Promise<Result<FSConfigInfo[]>> => {
  return $http.get({
    url: '/monitor/fss',
  });
};

/**
 * 获得SessionCenter 图表数据
 */
export const getSCGraphData = (
  scName: string,
  data: { beginTime?: string; endTime?: string; interval?: number }
): Promise<Result<SessionCenterGraphInfo[]>> => {
  return $http.get({
    url: `/monitor/scs/${scName}/monitoritem`,
    data,
  });
};

/**
 * 获得SessionCenter监控表格数据
 */
export const getSCTableData = (data: {
  beginTime?: string;
  endTime?: string;
}): Promise<Result<SessionCenterTableInfo[]>> => {
  return $http.get({
    url: '/monitor/scs/monitorlist',
    data,
  });
};

/**
 * 修改SessionCenter项
 */
export const modifySCConfig = (data: SessionCenterConfigInfo[]) => {
  return $http.post({
    url: `/monitor/scs`,
    data,
  });
};

/**
 * 获取SessionCenter项列表
 */
export const getSCConfigList = (): Promise<Result<SessionCenterConfigInfo[]>> => {
  return $http.get({
    url: '/monitor/scs',
  });
};
